﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                    xmlns:vsm="clr-namespace:System.Windows;assembly=WPFToolkit" 
                    xmlns:hsl="clr-namespace:HackingSilverlightLibrary" >
    <Style TargetType="hsl:FX">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="hsl:FX">
                    <Border >
                        <vsm:VisualStateManager.VisualStateGroups>
                            <vsm:VisualStateGroup x:Name="VisualStateGroup">
                                <vsm:VisualState x:Name="FlipState1">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="FrontScale" Storyboard.TargetProperty="ScaleX" To="0" Duration="0:0:.2" />
                                        <DoubleAnimation Storyboard.TargetName="FrontScale" Storyboard.TargetProperty="ScaleY" To=".95" Duration="0:0:.2" />
                                        <DoubleAnimation Storyboard.TargetName="FrontPanel" Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:.1" BeginTime="0:0:.1" />
                                        <DoubleAnimation Storyboard.TargetName="BackPanel" Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:.1" BeginTime="0:0:.1" />
                                        <DoubleAnimation Storyboard.TargetName="BackScale" Storyboard.TargetProperty="ScaleX" To="1" Duration="0:0:.2" BeginTime="0:0:.2" />
                                        <DoubleAnimation Storyboard.TargetName="BackScale" Storyboard.TargetProperty="ScaleY" To="1" Duration="0:0:.2" BeginTime="0:0:.2" />
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="FlipState2">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="BackScale" Storyboard.TargetProperty="ScaleX" To="0" Duration="0:0:.2" />
                                        <DoubleAnimation Storyboard.TargetName="BackScale" Storyboard.TargetProperty="ScaleY" To=".95" Duration="0:0:.2" />
                                        <DoubleAnimation Storyboard.TargetName="BackPanel" Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:.1" BeginTime="0:0:.1" />
                                        <DoubleAnimation Storyboard.TargetName="FrontPanel" Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:.1" BeginTime="0:0:.1" />
                                        <DoubleAnimation Storyboard.TargetName="FrontScale" Storyboard.TargetProperty="ScaleX" To="1" Duration="0:0:.2" BeginTime="0:0:.2" />
                                        <DoubleAnimation Storyboard.TargetName="FrontScale" Storyboard.TargetProperty="ScaleY" To="1" Duration="0:0:.2" BeginTime="0:0:.2" />
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                        </vsm:VisualStateManager.VisualStateGroups>
                        <Grid x:Name="ContentPresenters" Background="Transparent" >
                            <ContentPresenter x:Name="FrontPanel" Content="{TemplateBinding Front}"  RenderTransformOrigin="0.5,0.5"  >
                                <ContentPresenter.RenderTransform>
                                    <TransformGroup>
                                        <ScaleTransform x:Name="FrontScale" ScaleX="1" ScaleY="1"/>
                                    </TransformGroup>
                                </ContentPresenter.RenderTransform>
                            </ContentPresenter>
                            <ContentPresenter x:Name="BackPanel" Content="{TemplateBinding Back}" Opacity="0" RenderTransformOrigin="0.5,0.5" >
                                <ContentPresenter.RenderTransform>
                                    <TransformGroup>
                                        <ScaleTransform x:Name="BackScale" ScaleX="0" ScaleY=".95"/>
                                    </TransformGroup>
                                </ContentPresenter.RenderTransform>
                            </ContentPresenter>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>